<template>
	<view>
		<view class="center">
			<image src="@/static/images/ss.png"></image>
			<input type="text" v-model="obj.keyWord" placeholder="请输入需要搜索的词汇" @input="fn" auto-focus />
		</view>
		<view v-for="(item,index) in list" class="list">
			<view class="dctit">{{item.word}}</view>
			<view>{{item.means}}</view>
		</view>
	</view>
</template>

<script>
	import {
		vagueSearch
	} from "../../utils/ciku.js"
	export default {
		data() {
			return {
				obj: {
					keyWord: '',
					count: 10
				},
				list: [],
			}
		},
		onReachBottom() {
			this.obj.count += 10
			this.chaxun()
		},
		methods: {
			fn() {
				if (this.obj.keyWord != '') {
					this.obj.count = 10
					this.chaxun()
				}

			},
			async chaxun() {
				uni.showLoading({
					title:"加载中..."
				})
				const {
					data: res
				} = await vagueSearch(this.obj)
				this.list = res.data
				uni.hideLoading()
			}

		}
	}
</script>

<style scoped>
	.center {
		margin: 10px 15px;
		display: flex;
		justify-content: center;
		align-items: center;
		background-color: #fff;
		border-radius: 5px;
		height: 35px;
		border: 2px solid #fff;
		box-sizing: border-box;
	}

	.center image {
		width: 18px;
		height: 18px;
		margin: 0 20px;
	}

	.center input {
		flex: 1;
	}

	.list {
		margin: 10px 15px;
		border-radius: 5px;
		background-color: #ffffff;
		padding: 10px 15px;
	}

	.dctit {
		color: #23B48D;
		font-weight: bold;
	}
</style>
